package com.schoolcloud.files.controller;

import com.schoolcloud.common.model.R;
import com.schoolcloud.files.entity.StorageBucket;
import com.schoolcloud.files.service.FileService;
import com.schoolcloud.files.service.StorageBucketService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bucket")
@RequiredArgsConstructor
public class BucketController {
    private final StorageBucketService storageBucketService;
    @GetMapping("/list")
    public R<List<StorageBucket>> getBucketList() {
        List<StorageBucket> list = storageBucketService.list();
        return R.ok(list);
    }
    @PostMapping
    public R<?> saveBucket(@RequestBody StorageBucket storageBucket) {
        boolean save = storageBucketService.createBucket(storageBucket);
        return save ? R.ok() : R.err();
    }
}
